import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-common-slide',
  templateUrl: './common-slide.component.html',
  styleUrls: ['./common-slide.component.scss']
})
export class CommonSlideComponent implements OnInit {
  @Input() slides: string[] = [];
  @Input() pageNumber: number = 5;
  @Input() selectedIndex: number = 0;
  @Output() slideClick = new EventEmitter<number>();

  mySlideOptions;

  constructor() {}

  ngOnInit() {
    this.mySlideOptions = {
      loop: false,
      autoplay: false,
      initialSlide: 0,//初始幻灯片的索引号。
      pager: false,
      slidesPerView: this.pageNumber,//每个视图的幻灯片数量（幻灯片在滑块容器上同时可见）。
      paginationHide: true,
      paginationClickable: true
    };
  }
  onClick(index) {
    this.selectedIndex = index;
    this.slideClick.emit(index);
  }
}
